package com.ledim.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.ledim.adapter.base.LedimBaseListAdapter;
import com.ledim.bean.FilterValBean;
import com.letv.android.young.client.R;
import java.util.ArrayList;

public class SubFiltersAdapter extends LedimBaseListAdapter<FilterValBean> {

    public int selectedPosition;

    public SubFiltersAdapter(Context context, ArrayList<FilterValBean> list) {
        super(context);
        setDatas(list);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_channels_horizantal_listview, null);
            holder.mName = (TextView) convertView.findViewById(R.id.tab_item_name);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        final FilterValBean value = getItem(position);
        holder.mName.setText(value.name);
        if (selectedPosition == position) {
            holder.mName.setBackgroundResource(R.drawable.rect_round_channel_bg);
            holder.mName.setTextColor(Color.parseColor("#1a1a1a"));
        } else {
            holder.mName.setTextColor(Color.parseColor("#666666"));
            holder.mName.setBackgroundColor(Color.parseColor("#ffffff"));
        }
        return convertView;
    }

    public static class ViewHolder {

        private TextView mName;
    }

    //listview选中的item
    public void setSelectItem(int position) {
        this.selectedPosition = position;
        notifyDataSetChanged();
    }
}
